package com.meida.student.app.scholartyrant.controller;

import com.meida.common.mybatis.model.ResultBody;
import com.meida.common.springmvc.base.BaseController;
import com.meida.module.bus.client.entity.BusOrder;
import com.meida.module.bus.client.entity.BusOrderAnswer;
import com.meida.module.bus.client.enums.OrderSearchStateEnum;
import com.meida.module.bus.client.enums.ScholarTyrantOrderSearchStateEnum;
import com.meida.module.bus.provider.service.BusOrderService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


/**
 * 订单表控制器
 *
 * @author flyme
 * @date 2021-08-03
 */
@RestController
@RequestMapping("/order/")
public class SOrderController extends BaseController<BusOrderService, BusOrder> {

    @ApiOperation(value = "领取题目", notes = "领取题目")
    @PostMapping(value = "receiveOrderQuestion")
    public ResultBody receiveOrderQuestion(Long orderId) {
        return bizService.receiveOrderQuestion(orderId);
    }

    @ApiOperation(value = "出价", notes = "出价")
    @PostMapping(value = "updateOfferPrice")
    public ResultBody updateOfferPrice(BusOrderAnswer busOrderAnswer) {
        return bizService.updateOfferPrice(busOrderAnswer);
    }


    @ApiOperation(value = "拒绝订单", notes = "拒绝订单")
    @PostMapping(value = "refuseOrder")
    public ResultBody refuseOrder(Long orderId) {
        return bizService.refuseOrder(orderId);
    }

    @ApiOperation(value = "接受预约", notes = "接受预约")
    @PostMapping(value = "acceptAppointment")
    public ResultBody acceptAppointment(@RequestParam(required = false) Map params) {
        return bizService.acceptAppointment(params);
    }

    @ApiOperation(value = "更改订单状态为解答中/上课中", notes = "更改订单状态为解答中/上课中")
    @PostMapping(value = "answerIng")
    public ResultBody answerIng(Long orderId) {
        return bizService.answerIng(orderId);
    }

    @ApiOperation(value = "订单状态定义", notes = "订单状态定义")
    @GetMapping(value = "orderStateList")
    public ResultBody orderStateList(Integer stateType) {
        if (stateType.equals(1)) {
            return ResultBody.ok(OrderSearchStateEnum.values());
        } else {
            return ResultBody.ok(ScholarTyrantOrderSearchStateEnum.values());
        }
    }
}
